<template>
	<div class="content-box">
		<Row>
            <i-col span="24">
                <user-bar></user-bar>
            </i-col>
		</Row>
		<br/>
		<Row  type="flex"  justify="center">
			<i-col span="23">
                <portlet name='自然人不良信息' :link="back">
                    <div>
                    	<i-form :model='formItem'>
                    		<Row>
            					<i-col span="6">
    	        					<Form-item v-for='infor in formItem.name'  track-by="$index" label="姓名"  :label-width="80">
    						            <i-input :value.sync="infor" placeholder="请输入"></i-input>
    						        </Form-item>
    						    </i-col>
    						    <i-col span="6">
    	        					<Form-item v-for='infor in formItem.ID'  track-by="$index" label="身份证号码"  :label-width="80">
    						            <i-input :value.sync="infor" placeholder="请输入"></i-input>
    						        </Form-item>
    						    </i-col>
                                <i-col span="12">
                    				<Form-item  :label-width="14">
            						    <i-button @click='request' type="primary">查询</i-button>
            						    <i-button @click='addItem' type="primary">添加</i-button>
            						    <i-button @click='showUp' type="primary">EXCEL导入查询</i-button>
            						</Form-item>
                                </i-col>
                            </Row>
                            <div class="upload_content" v-if='showUpLoad'>
                                <input name='file' type='file' id='excel'/>
                                <i-button @click='upload' type="primary">点击上传</i-button>
                            </div>
                    	</i-form>
                    </div>
                    <div>
                    	<i-table :columns="columns1" :data="results"></i-table>
                        <div class="excel_out">
                            <a :href="this.path+'product/productServlet/excelOutBadImport'">EXCEL导出</a>
                            <!-- <i-button  @click='exportExcel' type="primary">EXCEL导出</i-button> -->
                        </div>
                    </div>
                </portlet>
            </i-col>
		</Row>
	</div>
</template>
<script>
	import userBar from '../finance/userBar.vue';
    import portlet from '../../components/portlet.vue';
	export default {
		components:{userBar,portlet},
		data(){
			return {
				formItem:{
					name:['',
					],
					ID:['',]
				},
				results:[],
				showUpLoad:false,
				columns1:[
					{
                        title: '姓名',
                        key: 'name'
                    },
                    {
                        title: '身份证号',
                        key: 'idCard'
                    },
                    {
                        title: '比中前科',
                        key: 'isMatch'
                    },
                    {
                        title: '身份是否匹配',
                        key: 'comparisonResult'
                    },
                    {
                        title: '案发时间倒序排列',
                        key: 'caseTime'
                    },
                    
				],
				back:{
                    text:'返回',
                    addr:'/app/productApply'
                },

			}
		},
		methods:{
			addItem(){
				this.formItem.name.push('');
				this.formItem.ID.push('');
			},
			request(){
				this.$http.jsonp(this.path+'product/productServlet/findBadInform',{
                    params:{userNameList:this.formItem.name.toString(),idCardList:this.formItem.ID.toString()},
                    jsonp:'callback'
                 }).then(
                    (datas)=>{
                        if(datas.body.code=='001'){
                            this.results=datas.body.result.rows;
                        }else{
                            this.$Message.success(datas.body.msg);
                            if(datas.body.code=='997'||datas.body.code=='998'){
                            	this.myRouter.go({path:'/login'});
                            }
                        }
                    },
                    (error)=>{
                        this.$Message.success('网络问题!');
                    }
                 );
			},
			showUp(){
				this.showUpLoad=!this.showUpLoad;
			},
            upload(){
                let files=document.querySelector('#excel').files[0];
                let myForm = new FormData()
                myForm.append("file",files);
                this.$http.post(this.path+'product/productServlet/badInformExcelImport',myForm).then((response)=>{
                    this.results=response.body.result.rows;
                },(error)=>{
                    alert('上传失败,请重试!');
                });

            },
            // exportExcel(){
            //     this.$http.get(this.path+'product/productServlet/excelOutBadImport',{
            //         params:{userNameList:this.formItem.name.toString(),idCardList:this.formItem.ID.toString()}
            //      }).then(
            //         (datas)=>{
            //             console.log(datas);
            //             if(datas.body.code=='001'){
                           
            //             }else{
            //                 this.$Message.success(datas.body.msg);
            //                 if(datas.body.code=='997'||datas.body.code=='998'){
            //                     this.myRouter.go({path:'/login'});
            //                 }
            //             }
            //         },
            //         (error)=>{
            //             this.$Message.success('网络问题!');
            //         }
            //     );
            // }
		}
	}
</script>
<style type="text/css">
	.upload_content{
        height: 200px;
        padding-top:90px;
        width: 600px;
        margin:0 auto;
    }
</style>